package test;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javax.swing.JOptionPane;

import org.apache.log4j.Logger;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.service.IoHandler;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

public class CommandHandler implements IoHandler {

    public CommandHandler() {
    }

    @Override
    public void exceptionCaught(IoSession arg0, Throwable arg1) throws Exception {
        // TODO Auto-generated method stub
    }

    @Override
    public void messageReceived(IoSession session, Object message) throws Exception {
        JOptionPane.showMessageDialog(null, "receive:" + message, "information", JOptionPane.INFORMATION_MESSAGE);
    }

    @Override
    public void messageSent(IoSession session, Object message) throws Exception {
        JOptionPane.showMessageDialog(null, "send:" + message, "information", JOptionPane.INFORMATION_MESSAGE);
    }

    @Override
    public void sessionClosed(IoSession session) throws Exception {
    }

    @Override
    public void sessionCreated(IoSession session) throws Exception {
        /*
		 * Target target = new Target(this.messageParser); target.WorkingMode =
		 * (short) this.workingMode; target.session = session;
		 * TargetAgent.getInstance().AddConnection(session.getId(), target); //
		 * query system address and state synchronized (this) {
		 * session.write(this.messageParser.RequestSystemData()); target.state =
		 * TargetCommandState.WaitingForSystemData; target.lastMessageTime =
		 * System.currentTimeMillis(); }
		 */
    }

    @Override
    public void sessionIdle(IoSession arg0, IdleStatus arg1) throws Exception {
        // TODO Auto-generated method stub

    }

    @Override
    public void sessionOpened(IoSession arg0) throws Exception {
        // TODO Auto-generated method stub

    }
}
